#include "dlg_login.h"
#include "ui_dlg_login.h"
#include "lib/sqlmgr.h"

#include <QMessageBox>

Dlg_login::Dlg_login(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::Dlg_login)
{
    ui->setupUi(this);
    ui->line_passwd->setEchoMode(QLineEdit::Password);
}

Dlg_login::~Dlg_login()
{
    delete ui;
}

void Dlg_login::on_btn_login_clicked()
{
    int bookid = 0;
    auto ret = SqlMgr::getInstance()->login(ui->line_usr->text(),ui->line_passwd->text(),bookid);
    if(ret)
    {
        setResult(1);
        hide();
    }
    else {
        QMessageBox::information(nullptr,"信息   ","用户名或者密码错误   ");
    }
}

void Dlg_login::on_btn_exit_clicked()
{
    setResult(0);
    hide(); //隐藏窗口
}
